package cn.tedu.charging.order.repository.impl;

import cn.tedu.charging.common.pojo.po.ChargingBillFailPO;
import cn.tedu.charging.common.pojo.po.ChargingBillSuccessPO;
import cn.tedu.charging.order.mapper.BillFailMapper;
import cn.tedu.charging.order.mapper.BillSuccessMapper;
import cn.tedu.charging.order.repository.BillRepository;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
@Slf4j
public class BillRepositoryImpl implements BillRepository {
    @Autowired
    private BillSuccessMapper billSuccessMapper;
    @Autowired
    private BillFailMapper billFailMapper;
    @Override
    public void saveBillSuccess(ChargingBillSuccessPO success) {
        billSuccessMapper.insert( success);
    }

    @Override
    public void saveBillFail(ChargingBillFailPO fail) {
        billFailMapper.insert(fail);
    }

    @Override
    public Long countSuccess(String billId) {
        QueryWrapper queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("bill_id",billId);
        return billSuccessMapper.selectCount(queryWrapper);
    }

    @Override
    public Long countFail(String billId) {
        QueryWrapper queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("bill_id",billId);
        return billFailMapper.selectCount(queryWrapper);
    }
}
